package com.example.juegoenandroid;

import java.io.*;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.util.Xml;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;

public class Score extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_score);
		
		TextView ver1=(TextView) findViewById(R.id.fichero);

		ArrayList<String> lista=new ArrayList<String>();
		FileInputStream fin = null;
		
		 try {
			 
			       fin = openFileInput("test.xml");
			
			    } catch (Exception e) {
			 
			       Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
			 
			    }
	 
			    XmlPullParser parser = Xml.newPullParser();
			 
			    try {
			 
			       parser.setInput(fin, "UTF-8");

			       int event = parser.next();
			 

			       while(event != XmlPullParser.END_DOCUMENT) {
			    	   
			    	  
			    	   if(event == XmlPullParser.START_TAG) {
			    		   
			    		  
			    		   
			    		               for(int i = 0; i < parser.getAttributeCount(); i++) {
			    		   
			    		            	   ver1.append( "\t" + parser.getAttributeName(i) + " = " + parser.getAttributeValue(i));
			    		   
			    		               }
			    		   
			    		            }	    		    
			    		    

	    	            event = parser.next();
	    	  
	    	         }

			       
			      
			       for(int i=0;i<lista.size();i++)
			       {
			    	 
			    	   ver1.append(lista.get(i).toString());
			       }
      
			       fin.close();
			 
			  
			 
			    } catch (Exception e) {
			 
			       Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
			 
			    }


	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.score, menu);
		return true;
	}

	protected void onRestart() {
		finish();
		super.onRestart();
	}
}
